package com.heima.user.controller;

import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.dtos.UserAuthDto;
import com.heima.user.service.ApUserAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserAuthController {

    @Autowired
    private ApUserAuthService apUserAuthService;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/auth/list")
    public PageResult<UserAuthDto> findByPage(@RequestBody AuthDto dto){
        return apUserAuthService.findByPage(dto);
    }

    /**
     * 通过
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/auth/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        apUserAuthService.userAuth(dto,9);
        return ResponseResult.ok();
    }

    /**
     * 不通过
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/auth/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        apUserAuthService.userAuth(dto,2);
        return ResponseResult.ok();
    }
}
